package sui

import (
	"context"
	"encoding/hex"
	"encoding/json"
	"errors"
	"fmt"
	"testing"
	"time"

	"github.com/certusone/wormhole/node/pkg/common"
	txverifier "github.com/certusone/wormhole/node/pkg/txverifier"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"github.com/wormhole-foundation/wormhole/sdk/vaa"
	"go.uber.org/zap"
)

func NewSuiWatcherForTest(msgChan chan *common.MessagePublication, suiTxVerifier *txverifier.SuiTransferVerifier, suiEventType string) *Watcher {
	return &Watcher{
		msgChan:           msgChan,
		suiMoveEventType:  suiEventType,
		suiTxVerifier:     suiTxVerifier,
		txVerifierEnabled: true,
	}
}

type MockSuiApiConnection struct {
	transactionBlockResponses      map[string]txverifier.SuiGetTransactionBlockResponse
	tryMultiGetPastObjectsResponse map[string]txverifier.SuiTryMultiGetPastObjectsResponse
}

func (m *MockSuiApiConnection) QueryEvents(ctx context.Context, filter string, cursor string, limit int, descending bool) (txverifier.SuiQueryEventsResponse, error) {
	return txverifier.SuiQueryEventsResponse{}, errors.New("Not supported")
}

func (m *MockSuiApiConnection) SetTransactionBlock(txDigest string, transactionBlockResponse txverifier.SuiGetTransactionBlockResponse) {
	m.transactionBlockResponses[txDigest] = transactionBlockResponse
}

func (m *MockSuiApiConnection) GetTransactionBlock(ctx context.Context, txDigest string) (txverifier.SuiGetTransactionBlockResponse, error) {
	if _, exists := m.transactionBlockResponses[txDigest]; !exists {
		return txverifier.SuiGetTransactionBlockResponse{}, errors.New("Could not find transaction block")
	}

	return m.transactionBlockResponses[txDigest], nil
}

func (m *MockSuiApiConnection) SetPastObjects(objectId string, version string, previousVersion string, pastObjectsResponse txverifier.SuiTryMultiGetPastObjectsResponse) {
	key := fmt.Sprintf("%s-%s-%s", objectId, version, previousVersion)
	m.tryMultiGetPastObjectsResponse[key] = pastObjectsResponse
}

func (m *MockSuiApiConnection) TryMultiGetPastObjects(ctx context.Context, objectId string, version string, previousVersion string) (txverifier.SuiTryMultiGetPastObjectsResponse, error) {
	key := fmt.Sprintf("%s-%s-%s", objectId, version, previousVersion)

	if _, exists := m.tryMultiGetPastObjectsResponse[key]; !exists {
		return txverifier.SuiTryMultiGetPastObjectsResponse{}, errors.New("Could not find past objects")
	}

	return m.tryMultiGetPastObjectsResponse[key], nil
}

func Test_JSONParseOneWHMSg(t *testing.T) {
	// JSON with only the first result (contains all of the fields in `FieldsData` - parses successfully)
	msg := []byte("{\"jsonrpc\":\"2.0\",\"result\":[{\"id\":{\"txDigest\":\"2Z4A1ND5JL8c5ma9WMzFXUvpVqnwoQdYuaX4RwnLyMXU\",\"eventSeq\":\"0\"},\"packageId\":\"0x826915f8ca6d11597dfe6599b8aa02a4c08bd8d39674855254a06ee83fe7220e\",\"transactionModule\":\"lending_portal_v2\",\"sender\":\"0xccce7bbffaf1b9e9e8ca88a68a08fec11f568a697023f475f99efb7bcee951cf\",\"type\":\"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::publish_message::WormholeMessage\",\"parsedJson\":{\"consistency_level\":0,\"nonce\":0,\"payload\":[0,1,0,34,0,0,204,206,123,191,250,241,185,233,232,202,136,166,138,8,254,193,31,86,138,105,112,35,244,117,249,158,251,123,206,233,81,207,2,0,133,0,0,0,0,0,0,0,0,10,202,0,0,0,10,122,53,130,0,0,76,0,0,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,50,58,58,115,117,105,58,58,83,85,73,0,34,0,0,204,206,123,191,250,241,185,233,232,202,136,166,138,8,254,193,31,86,138,105,112,35,244,117,249,158,251,123,206,233,81,207,2],\"sender\":\"0xdd1ca0bd0b9e449ff55259e5bcf7e0fc1b8b7ab49aabad218681ccce7b202bd6\",\"sequence\":\"2768\",\"timestamp\":\"1693091880\"},\"bcs\":\"J8cfJrtMWT2kg6uBgWQmd8T9k9cSibQg65ufpgxugVM2ghgC8bb1vvqoXmETiMvfb9DJLEDKy2pnvAYivyWJfz8zKSn5u7EfDbMntpszG7D4gsNNu9cU2rMUi4aF7DXnv6QAp5hoaHvJymehRwXkncHfjZ7zKsZ8cUtSKJh6S6YjHMRZ67s1PPwGEVwUdQt5S3WhQdag3tuySe8FDrUWgJfbBawyUKLdbNcR1aXFtBiPu6jQ51BF7sv13x9hp2nbs5EUMYjnN1ykK4YQaKx55eY7TQcxVCRzPrEARSkMjB8VgqefLNpwiCRdq\"}],\"id\":1}")
	expectedPayload := []byte{0, 1, 0, 34, 0, 0, 204, 206, 123, 191, 250, 241, 185, 233, 232, 202, 136, 166, 138, 8, 254, 193, 31, 86, 138, 105, 112, 35, 244, 117, 249, 158, 251, 123, 206, 233, 81, 207, 2, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 10, 202, 0, 0, 0, 10, 122, 53, 130, 0, 0, 76, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 50, 58, 58, 115, 117, 105, 58, 58, 83, 85, 73, 0, 34, 0, 0, 204, 206, 123, 191, 250, 241, 185, 233, 232, 202, 136, 166, 138, 8, 254, 193, 31, 86, 138, 105, 112, 35, 244, 117, 249, 158, 251, 123, 206, 233, 81, 207, 2}

	var res SuiTxnQuery
	err := json.Unmarshal(msg, &res)
	require.NoError(t, err)
	for _, chunk := range res.Result {
		// chunk is a SuiResult
		// fmt.Println("body.Type", *chunk.Type)
		assert.Equal(t, "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::publish_message::WormholeMessage", *chunk.Type)
		var fields FieldsData
		err := json.Unmarshal(*chunk.Fields, &fields)
		require.NoError(t, err)

		assert.Equal(t, uint8(0), *fields.ConsistencyLevel)
		assert.Equal(t, uint64(0), *fields.Nonce)
		assert.Equal(t, expectedPayload, fields.Payload)
		assert.Equal(t, "0xdd1ca0bd0b9e449ff55259e5bcf7e0fc1b8b7ab49aabad218681ccce7b202bd6", *fields.Sender)
		assert.Equal(t, "2768", *fields.Sequence)
		assert.Equal(t, "1693091880", *fields.Timestamp)
	}
}

func Test_JSONParseMultipleMsgs(t *testing.T) {
	// Original JSON (fails to parse)
	msg := []byte("{\"jsonrpc\":\"2.0\",\"result\":[{\"id\":{\"txDigest\":\"2Z4A1ND5JL8c5ma9WMzFXUvpVqnwoQdYuaX4RwnLyMXU\",\"eventSeq\":\"0\"},\"packageId\":\"0x826915f8ca6d11597dfe6599b8aa02a4c08bd8d39674855254a06ee83fe7220e\",\"transactionModule\":\"lending_portal_v2\",\"sender\":\"0xccce7bbffaf1b9e9e8ca88a68a08fec11f568a697023f475f99efb7bcee951cf\",\"type\":\"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::publish_message::WormholeMessage\",\"parsedJson\":{\"consistency_level\":0,\"nonce\":0,\"payload\":[0,1,0,34,0,0,204,206,123,191,250,241,185,233,232,202,136,166,138,8,254,193,31,86,138,105,112,35,244,117,249,158,251,123,206,233,81,207,2,0,133,0,0,0,0,0,0,0,0,10,202,0,0,0,10,122,53,130,0,0,76,0,0,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,50,58,58,115,117,105,58,58,83,85,73,0,34,0,0,204,206,123,191,250,241,185,233,232,202,136,166,138,8,254,193,31,86,138,105,112,35,244,117,249,158,251,123,206,233,81,207,2],\"sender\":\"0xdd1ca0bd0b9e449ff55259e5bcf7e0fc1b8b7ab49aabad218681ccce7b202bd6\",\"sequence\":\"2768\",\"timestamp\":\"1693091880\"},\"bcs\":\"J8cfJrtMWT2kg6uBgWQmd8T9k9cSibQg65ufpgxugVM2ghgC8bb1vvqoXmETiMvfb9DJLEDKy2pnvAYivyWJfz8zKSn5u7EfDbMntpszG7D4gsNNu9cU2rMUi4aF7DXnv6QAp5hoaHvJymehRwXkncHfjZ7zKsZ8cUtSKJh6S6YjHMRZ67s1PPwGEVwUdQt5S3WhQdag3tuySe8FDrUWgJfbBawyUKLdbNcR1aXFtBiPu6jQ51BF7sv13x9hp2nbs5EUMYjnN1ykK4YQaKx55eY7TQcxVCRzPrEARSkMjB8VgqefLNpwiCRdq\"},{\"id\":{\"txDigest\":\"2Z4A1ND5JL8c5ma9WMzFXUvpVqnwoQdYuaX4RwnLyMXU\",\"eventSeq\":\"1\"},\"packageId\":\"0x826915f8ca6d11597dfe6599b8aa02a4c08bd8d39674855254a06ee83fe7220e\",\"transactionModule\":\"lending_portal_v2\",\"sender\":\"0xccce7bbffaf1b9e9e8ca88a68a08fec11f568a697023f475f99efb7bcee951cf\",\"type\":\"0x826915f8ca6d11597dfe6599b8aa02a4c08bd8d39674855254a06ee83fe7220e::wormhole_adapter_pool::RelayEvent\",\"parsedJson\":{\"app_id\":1,\"call_type\":2,\"fee_amount\":\"57821069\",\"nonce\":\"2762\",\"sequence\":\"2768\"},\"bcs\":\"V7pAXEvqBvtV5ps2fetket9wYhsoQT1Y8X6bT\"},{\"id\":{\"txDigest\":\"2Z4A1ND5JL8c5ma9WMzFXUvpVqnwoQdYuaX4RwnLyMXU\",\"eventSeq\":\"2\"},\"packageId\":\"0x826915f8ca6d11597dfe6599b8aa02a4c08bd8d39674855254a06ee83fe7220e\",\"transactionModule\":\"lending_portal_v2\",\"sender\":\"0xccce7bbffaf1b9e9e8ca88a68a08fec11f568a697023f475f99efb7bcee951cf\",\"type\":\"0x826915f8ca6d11597dfe6599b8aa02a4c08bd8d39674855254a06ee83fe7220e::lending_portal_v2::LendingPortalEvent\",\"parsedJson\":{\"amount\":\"45000000000\",\"call_type\":2,\"dola_pool_address\":[48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,50,58,58,115,117,105,58,58,83,85,73],\"dst_chain_id\":0,\"nonce\":\"2762\",\"receiver\":[204,206,123,191,250,241,185,233,232,202,136,166,138,8,254,193,31,86,138,105,112,35,244,117,249,158,251,123,206,233,81,207],\"sender\":\"0xccce7bbffaf1b9e9e8ca88a68a08fec11f568a697023f475f99efb7bcee951cf\",\"source_chain_id\":0},\"bcs\":\"U7Gg8eey15TjPBGfZcKPCnYHJ84s3pL2BYUaw4r3NjK8AcWfzgKqsgW9F27yhPBtQdytETbAVqfx6b2Xsw7Ypprnbym5UEzyLHzuS79PMaAbGrXtVmdDYeHnoQ3DjfCSVZ5fZEaENLmmhe5m4iEYdkrjjaujoVQtuoFqjzaXYbMj89oksCE3E19PWsKzP7DVDcC99JjphepJgtGjQhCvdtzLd8kR\"}],\"id\":1}")
	expectedPayload := []byte{0, 1, 0, 34, 0, 0, 204, 206, 123, 191, 250, 241, 185, 233, 232, 202, 136, 166, 138, 8, 254, 193, 31, 86, 138, 105, 112, 35, 244, 117, 249, 158, 251, 123, 206, 233, 81, 207, 2, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 10, 202, 0, 0, 0, 10, 122, 53, 130, 0, 0, 76, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 50, 58, 58, 115, 117, 105, 58, 58, 83, 85, 73, 0, 34, 0, 0, 204, 206, 123, 191, 250, 241, 185, 233, 232, 202, 136, 166, 138, 8, 254, 193, 31, 86, 138, 105, 112, 35, 244, 117, 249, 158, 251, 123, 206, 233, 81, 207, 2}

	var res SuiTxnQuery
	err := json.Unmarshal(msg, &res)
	require.NoError(t, err)

	for _, chunk := range res.Result {
		// chunk is a SuiResult
		if *chunk.Type != "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::publish_message::WormholeMessage" {
			continue
		}
		var fields FieldsData
		err := json.Unmarshal(*chunk.Fields, &fields)
		require.NoError(t, err)

		assert.Equal(t, uint8(0), *fields.ConsistencyLevel)
		assert.Equal(t, uint64(0), *fields.Nonce)
		assert.Equal(t, expectedPayload, fields.Payload)
		assert.Equal(t, "0xdd1ca0bd0b9e449ff55259e5bcf7e0fc1b8b7ab49aabad218681ccce7b202bd6", *fields.Sender)
		assert.Equal(t, "2768", *fields.Sequence)
		assert.Equal(t, "1693091880", *fields.Timestamp)
	}
}

func decodeStringNoError(s string) []byte {
	b, _ := hex.DecodeString(s)
	return b
}

var (
	Samples = []struct {
		description        string
		expectedState      common.VerificationState
		txDigest           string
		transactionBlock   []byte
		pastObjects        []byte
		messagePublication common.MessagePublication
	}{
		// native
		{
			description:      "NativeStandard",
			expectedState:    common.Valid,
			txDigest:         "3dFwinvN8cxotrbHmisT1zMnFiFeR5nowo9zzZw7akin",
			transactionBlock: []byte(`{"jsonrpc":"2.0","id":1,"result":{"digest":"3dFwinvN8cxotrbHmisT1zMnFiFeR5nowo9zzZw7akin","events":[{"id":{"txDigest":"3dFwinvN8cxotrbHmisT1zMnFiFeR5nowo9zzZw7akin","eventSeq":"0"},"packageId":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a","transactionModule":"publish_message","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::publish_message::WormholeMessage","parsedJson":{"consistency_level":0,"nonce":99916,"payload":[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,163,155,161,114,94,204,137,252,194,47,13,19,222,54,136,185,79,161,109,100,162,32,121,24,106,148,25,20,40,12,103,16,31,247,84,38,60,0,21,0,0,0,0,0,0,0,0,0,0,0,0,101,168,240,123,217,168,89,142,27,91,108,10,136,244,119,157,188,7,118,117,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"sender":"0xccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5","sequence":"211135","timestamp":"1747215154"},"bcsEncoding":"base64","bcs":"zM7rKTSPcb3SL/70OioZwfW14XxcylQRUpEgGCZyreW/OAMAAAAAAEyGAQCFAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACjm6FyXsyJ/MIvDRPeNoi5T6FtZKIgeRhqlBkUKAxnEB/3VCY8ABUAAAAAAAAAAAAAAABlqPB72ahZjhtbbAqI9HedvAd2dQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMmMkaAAAAAA="}],"objectChanges":[{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"AddressOwner":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1"},"objectType":"0x2::coin::Coin<0x2::sui::SUI>","objectId":"0x06c1e8523e69f625f4fc1482dd42f8db436ec7607197e0671f5baa39684d4370","version":"556965531","previousVersion":"556965171","digest":"99BZLA3UVxr9XqmTQzakQ8uTmk35R6JyWBa1eiCgpJgx"},{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"AddressOwner":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1"},"objectType":"0x2::coin::Coin<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","objectId":"0x147df1a75dff16a5e7ee966d41b966e718cc27177e67855a876fb780fde7d43e","version":"556965531","previousVersion":"556965171","digest":"Gp6qVFxHzTc8rm5TCQPxhCpBoWprPh2StLHfH1NTG3es"},{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"ObjectOwner":"0x334881831bd89287554a6121087e498fa023ce52c037001b53a4563a00a281a5"},"objectType":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>>","objectId":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12","version":"556965531","previousVersion":"556963430","digest":"3tAkXi77Dui24ShRNvzSdjnfk4HabjQpfYKvEDrnm5JQ"},{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"Shared":{"initial_shared_version":64}},"objectType":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::state::State","objectId":"0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c","version":"556965531","previousVersion":"556965530","digest":"FYtqG5uY7ymFB3BYn9jGArQ6xppEsC4VfhQxR6qGAT3s"},{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"Shared":{"initial_shared_version":66}},"objectType":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::state::State","objectId":"0xc57508ee0d4595e5a8728974a4a93a787d38f339757230d441e895422c07aba9","version":"556965531","previousVersion":"556964077","digest":"MoQndo45yEjj1bQeDXUyCnC75Sd4SGoaMhuZRR4XpCF"},{"type":"created","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"AddressOwner":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1"},"objectType":"0x2::coin::Coin<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","objectId":"0xc0339b6a32e521cd689f5b74a8d2b1b9fad1f72c292c0ed81ef18c20b1847541","version":"556965531","digest":"AHQAsewynGkrB3iNmaaN7uCYeRnFXagKWucXKhcv5pEC"}],"timestampMs":"1747215154277","checkpoint":"145024142"}}`),
			pastObjects:      []byte(`{"jsonrpc":"2.0","id":1,"result":[{"status":"VersionFound","details":{"objectId":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12","version":"556965531","digest":"3tAkXi77Dui24ShRNvzSdjnfk4HabjQpfYKvEDrnm5JQ","content":{"dataType":"moveObject","type":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>>","hasPublicTransfer":false,"fields":{"id":{"id":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12"},"name":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","fields":{"dummy_field":false}},"value":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","fields":{"custody":"49570703852513680","decimals":9,"token_address":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::external_address::ExternalAddress","fields":{"value":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::bytes32::Bytes32","fields":{"data":[204,137,252,194,47,13,19,222,54,136,185,79,161,109,100,162,32,121,24,106,148,25,20,40,12,103,16,31,247,84,38,60]}}}}}}}}}},{"status":"VersionFound","details":{"objectId":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12","version":"556963430","digest":"CTtUsqT2kGCFJ9AWYkKEYSLxN1J68Hj1M92iaX2bS4sm","content":{"dataType":"moveObject","type":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>>","hasPublicTransfer":false,"fields":{"id":{"id":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12"},"name":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","fields":{"dummy_field":false}},"value":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","fields":{"custody":"49563676945330660","decimals":9,"token_address":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::external_address::ExternalAddress","fields":{"value":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::bytes32::Bytes32","fields":{"data":[204,137,252,194,47,13,19,222,54,136,185,79,161,109,100,162,32,121,24,106,148,25,20,40,12,103,16,31,247,84,38,60]}}}}}}}}}}]}`),
			messagePublication: common.MessagePublication{
				TxID:             []byte("3dFwinvN8cxotrbHmisT1zMnFiFeR5nowo9zzZw7akin"),
				Timestamp:        time.UnixMilli(1747215154),
				Nonce:            99916,
				Sequence:         211135,
				ConsistencyLevel: 0,
				EmitterChain:     21,
				EmitterAddress:   vaa.Address(decodeStringNoError("ccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5")),
				Payload:          decodeStringNoError("01000000000000000000000000000000000000000000000000000000a39ba1725ecc89fcc22f0d13de3688b94fa16d64a22079186a941914280c67101ff754263c001500000000000000000000000065a8f07bd9a8598e1b5b6c0a88f4779dbc07767500040000000000000000000000000000000000000000000000000000000000000000"),
			},
		},
		{
			description:      "NativeLowerDepositThanRequired",
			expectedState:    common.Anomalous,
			txDigest:         "3dFwinvN8cxotrbHmisT1zMnFiFeR5nowo9zzZw7akin",
			transactionBlock: []byte(`{"jsonrpc":"2.0","id":1,"result":{"digest":"3dFwinvN8cxotrbHmisT1zMnFiFeR5nowo9zzZw7akin","events":[{"id":{"txDigest":"3dFwinvN8cxotrbHmisT1zMnFiFeR5nowo9zzZw7akin","eventSeq":"0"},"packageId":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a","transactionModule":"publish_message","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::publish_message::WormholeMessage","parsedJson":{"consistency_level":0,"nonce":99916,"payload":[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,163,155,161,114,94,204,137,252,194,47,13,19,222,54,136,185,79,161,109,100,162,32,121,24,106,148,25,20,40,12,103,16,31,247,84,38,60,0,21,0,0,0,0,0,0,0,0,0,0,0,0,101,168,240,123,217,168,89,142,27,91,108,10,136,244,119,157,188,7,118,117,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"sender":"0xccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5","sequence":"211135","timestamp":"1747215154"},"bcsEncoding":"base64","bcs":"zM7rKTSPcb3SL/70OioZwfW14XxcylQRUpEgGCZyreW/OAMAAAAAAEyGAQCFAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACjm6FyXsyJ/MIvDRPeNoi5T6FtZKIgeRhqlBkUKAxnEB/3VCY8ABUAAAAAAAAAAAAAAABlqPB72ahZjhtbbAqI9HedvAd2dQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMmMkaAAAAAA="}],"objectChanges":[{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"AddressOwner":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1"},"objectType":"0x2::coin::Coin<0x2::sui::SUI>","objectId":"0x06c1e8523e69f625f4fc1482dd42f8db436ec7607197e0671f5baa39684d4370","version":"556965531","previousVersion":"556965171","digest":"99BZLA3UVxr9XqmTQzakQ8uTmk35R6JyWBa1eiCgpJgx"},{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"AddressOwner":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1"},"objectType":"0x2::coin::Coin<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","objectId":"0x147df1a75dff16a5e7ee966d41b966e718cc27177e67855a876fb780fde7d43e","version":"556965531","previousVersion":"556965171","digest":"Gp6qVFxHzTc8rm5TCQPxhCpBoWprPh2StLHfH1NTG3es"},{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"ObjectOwner":"0x334881831bd89287554a6121087e498fa023ce52c037001b53a4563a00a281a5"},"objectType":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>>","objectId":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12","version":"556965531","previousVersion":"556963430","digest":"3tAkXi77Dui24ShRNvzSdjnfk4HabjQpfYKvEDrnm5JQ"},{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"Shared":{"initial_shared_version":64}},"objectType":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::state::State","objectId":"0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c","version":"556965531","previousVersion":"556965530","digest":"FYtqG5uY7ymFB3BYn9jGArQ6xppEsC4VfhQxR6qGAT3s"},{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"Shared":{"initial_shared_version":66}},"objectType":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::state::State","objectId":"0xc57508ee0d4595e5a8728974a4a93a787d38f339757230d441e895422c07aba9","version":"556965531","previousVersion":"556964077","digest":"MoQndo45yEjj1bQeDXUyCnC75Sd4SGoaMhuZRR4XpCF"},{"type":"created","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"AddressOwner":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1"},"objectType":"0x2::coin::Coin<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","objectId":"0xc0339b6a32e521cd689f5b74a8d2b1b9fad1f72c292c0ed81ef18c20b1847541","version":"556965531","digest":"AHQAsewynGkrB3iNmaaN7uCYeRnFXagKWucXKhcv5pEC"}],"timestampMs":"1747215154277","checkpoint":"145024142"}}`),
			pastObjects:      []byte(`{"jsonrpc":"2.0","id":1,"result":[{"status":"VersionFound","details":{"objectId":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12","version":"556965531","digest":"3tAkXi77Dui24ShRNvzSdjnfk4HabjQpfYKvEDrnm5JQ","content":{"dataType":"moveObject","type":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>>","hasPublicTransfer":false,"fields":{"id":{"id":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12"},"name":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","fields":{"dummy_field":false}},"value":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","fields":{"custody":"49570703852513680","decimals":9,"token_address":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::external_address::ExternalAddress","fields":{"value":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::bytes32::Bytes32","fields":{"data":[204,137,252,194,47,13,19,222,54,136,185,79,161,109,100,162,32,121,24,106,148,25,20,40,12,103,16,31,247,84,38,60]}}}}}}}}}},{"status":"VersionFound","details":{"objectId":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12","version":"556963430","digest":"CTtUsqT2kGCFJ9AWYkKEYSLxN1J68Hj1M92iaX2bS4sm","content":{"dataType":"moveObject","type":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>>","hasPublicTransfer":false,"fields":{"id":{"id":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12"},"name":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","fields":{"dummy_field":false}},"value":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","fields":{"custody":"49563676945331660","decimals":9,"token_address":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::external_address::ExternalAddress","fields":{"value":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::bytes32::Bytes32","fields":{"data":[204,137,252,194,47,13,19,222,54,136,185,79,161,109,100,162,32,121,24,106,148,25,20,40,12,103,16,31,247,84,38,60]}}}}}}}}}}]}`),
			messagePublication: common.MessagePublication{
				TxID:             []byte("3dFwinvN8cxotrbHmisT1zMnFiFeR5nowo9zzZw7akin"),
				Timestamp:        time.UnixMilli(1747215154),
				Nonce:            99916,
				Sequence:         211135,
				ConsistencyLevel: 0,
				EmitterChain:     21,
				EmitterAddress:   vaa.Address(decodeStringNoError("ccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5")),
				Payload:          decodeStringNoError("01000000000000000000000000000000000000000000000000000000a39ba1725ecc89fcc22f0d13de3688b94fa16d64a22079186a941914280c67101ff754263c001500000000000000000000000065a8f07bd9a8598e1b5b6c0a88f4779dbc07767500040000000000000000000000000000000000000000000000000000000000000000"),
			},
		},
		{
			description:      "NativeHigherDepositThanRequired",
			expectedState:    common.Valid,
			txDigest:         "3dFwinvN8cxotrbHmisT1zMnFiFeR5nowo9zzZw7akin",
			transactionBlock: []byte(`{"jsonrpc":"2.0","id":1,"result":{"digest":"3dFwinvN8cxotrbHmisT1zMnFiFeR5nowo9zzZw7akin","events":[{"id":{"txDigest":"3dFwinvN8cxotrbHmisT1zMnFiFeR5nowo9zzZw7akin","eventSeq":"0"},"packageId":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a","transactionModule":"publish_message","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::publish_message::WormholeMessage","parsedJson":{"consistency_level":0,"nonce":99916,"payload":[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,163,155,161,114,94,204,137,252,194,47,13,19,222,54,136,185,79,161,109,100,162,32,121,24,106,148,25,20,40,12,103,16,31,247,84,38,60,0,21,0,0,0,0,0,0,0,0,0,0,0,0,101,168,240,123,217,168,89,142,27,91,108,10,136,244,119,157,188,7,118,117,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"sender":"0xccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5","sequence":"211135","timestamp":"1747215154"},"bcsEncoding":"base64","bcs":"zM7rKTSPcb3SL/70OioZwfW14XxcylQRUpEgGCZyreW/OAMAAAAAAEyGAQCFAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACjm6FyXsyJ/MIvDRPeNoi5T6FtZKIgeRhqlBkUKAxnEB/3VCY8ABUAAAAAAAAAAAAAAABlqPB72ahZjhtbbAqI9HedvAd2dQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMmMkaAAAAAA="}],"objectChanges":[{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"AddressOwner":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1"},"objectType":"0x2::coin::Coin<0x2::sui::SUI>","objectId":"0x06c1e8523e69f625f4fc1482dd42f8db436ec7607197e0671f5baa39684d4370","version":"556965531","previousVersion":"556965171","digest":"99BZLA3UVxr9XqmTQzakQ8uTmk35R6JyWBa1eiCgpJgx"},{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"AddressOwner":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1"},"objectType":"0x2::coin::Coin<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","objectId":"0x147df1a75dff16a5e7ee966d41b966e718cc27177e67855a876fb780fde7d43e","version":"556965531","previousVersion":"556965171","digest":"Gp6qVFxHzTc8rm5TCQPxhCpBoWprPh2StLHfH1NTG3es"},{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"ObjectOwner":"0x334881831bd89287554a6121087e498fa023ce52c037001b53a4563a00a281a5"},"objectType":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>>","objectId":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12","version":"556965531","previousVersion":"556963430","digest":"3tAkXi77Dui24ShRNvzSdjnfk4HabjQpfYKvEDrnm5JQ"},{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"Shared":{"initial_shared_version":64}},"objectType":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::state::State","objectId":"0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c","version":"556965531","previousVersion":"556965530","digest":"FYtqG5uY7ymFB3BYn9jGArQ6xppEsC4VfhQxR6qGAT3s"},{"type":"mutated","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"Shared":{"initial_shared_version":66}},"objectType":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::state::State","objectId":"0xc57508ee0d4595e5a8728974a4a93a787d38f339757230d441e895422c07aba9","version":"556965531","previousVersion":"556964077","digest":"MoQndo45yEjj1bQeDXUyCnC75Sd4SGoaMhuZRR4XpCF"},{"type":"created","sender":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1","owner":{"AddressOwner":"0x53221ea79a11e3a6046282e7a246ef8472fdb31727018cb048d72e541d67e6f1"},"objectType":"0x2::coin::Coin<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","objectId":"0xc0339b6a32e521cd689f5b74a8d2b1b9fad1f72c292c0ed81ef18c20b1847541","version":"556965531","digest":"AHQAsewynGkrB3iNmaaN7uCYeRnFXagKWucXKhcv5pEC"}],"timestampMs":"1747215154277","checkpoint":"145024142"}}`),
			pastObjects:      []byte(`{"jsonrpc":"2.0","id":1,"result":[{"status":"VersionFound","details":{"objectId":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12","version":"556965531","digest":"3tAkXi77Dui24ShRNvzSdjnfk4HabjQpfYKvEDrnm5JQ","content":{"dataType":"moveObject","type":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>>","hasPublicTransfer":false,"fields":{"id":{"id":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12"},"name":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","fields":{"dummy_field":false}},"value":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","fields":{"custody":"49570703852513680","decimals":9,"token_address":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::external_address::ExternalAddress","fields":{"value":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::bytes32::Bytes32","fields":{"data":[204,137,252,194,47,13,19,222,54,136,185,79,161,109,100,162,32,121,24,106,148,25,20,40,12,103,16,31,247,84,38,60]}}}}}}}}}},{"status":"VersionFound","details":{"objectId":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12","version":"556963430","digest":"CTtUsqT2kGCFJ9AWYkKEYSLxN1J68Hj1M92iaX2bS4sm","content":{"dataType":"moveObject","type":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>>","hasPublicTransfer":false,"fields":{"id":{"id":"0x42b272eb5cf166861245cb82c0adc98fc9982c496cc8869a141031d3c4fe3b12"},"name":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","fields":{"dummy_field":false}},"value":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::native_asset::NativeAsset<0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL>","fields":{"custody":"49563676945320660","decimals":9,"token_address":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::external_address::ExternalAddress","fields":{"value":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::bytes32::Bytes32","fields":{"data":[204,137,252,194,47,13,19,222,54,136,185,79,161,109,100,162,32,121,24,106,148,25,20,40,12,103,16,31,247,84,38,60]}}}}}}}}}}]}`),
			messagePublication: common.MessagePublication{
				TxID:             []byte("3dFwinvN8cxotrbHmisT1zMnFiFeR5nowo9zzZw7akin"),
				Timestamp:        time.UnixMilli(1747215154),
				Nonce:            99916,
				Sequence:         211135,
				ConsistencyLevel: 0,
				EmitterChain:     21,
				EmitterAddress:   vaa.Address(decodeStringNoError("ccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5")),
				Payload:          decodeStringNoError("01000000000000000000000000000000000000000000000000000000a39ba1725ecc89fcc22f0d13de3688b94fa16d64a22079186a941914280c67101ff754263c001500000000000000000000000065a8f07bd9a8598e1b5b6c0a88f4779dbc07767500040000000000000000000000000000000000000000000000000000000000000000"),
			},
		},
		// wrapped
		{
			description:      "WwrappedStandard",
			expectedState:    common.Valid,
			txDigest:         "3YTfDnRtnLTx1wKR669jjFHznAxCXLHQZkshwk7K2oTw",
			transactionBlock: []byte(`{"jsonrpc":"2.0","id":1,"result":{"digest":"3YTfDnRtnLTx1wKR669jjFHznAxCXLHQZkshwk7K2oTw","events":[{"id":{"txDigest":"3YTfDnRtnLTx1wKR669jjFHznAxCXLHQZkshwk7K2oTw","eventSeq":"0"},"packageId":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a","transactionModule":"publish_message","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::publish_message::WormholeMessage","parsedJson":{"consistency_level":0,"nonce":0,"payload":[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,246,192,201,139,206,1,14,96,175,237,178,39,23,189,99,25,47,84,20,90,63,150,90,51,187,130,210,199,2,158,178,206,30,32,130,100,0,1,47,30,154,29,89,37,174,13,50,143,132,52,155,181,179,234,150,230,32,17,198,224,209,83,147,55,227,252,25,113,159,134,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"sender":"0xccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5","sequence":"211162","timestamp":"1747278630"},"bcsEncoding":"base64","bcs":"zM7rKTSPcb3SL/70OioZwfW14XxcylQRUpEgGCZyreXaOAMAAAAAAAAAAACFAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9sDJi84BDmCv7bInF71jGS9UFFo/llozu4LSxwKess4eIIJkAAEvHpodWSWuDTKPhDSbtbPqluYgEcbg0VOTN+P8GXGfhgABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJlslaAAAAAA="}],"objectChanges":[{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"AddressOwner":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01"},"objectType":"0x2::coin::Coin<0x2::sui::SUI>","objectId":"0x58e20782ae501807df528e19d43b8c5a1838cfd1f48a33597be4619c18c24f80","version":"557493695","previousVersion":"557350969","digest":"2vNHn2448gNgHWWzsKz1bZ7K4SfgWd4s7zRfCCVSdMM1"},{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"Shared":{"initial_shared_version":64}},"objectType":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::state::State","objectId":"0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c","version":"557493695","previousVersion":"557493694","digest":"7JB9FuS1jJcP79PmwQhFu3s78JmJ1XPCj6CbXJhwziQk"},{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"ObjectOwner":"0x334881831bd89287554a6121087e498fa023ce52c037001b53a4563a00a281a5"},"objectType":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>>","objectId":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd","version":"557493695","previousVersion":"557350964","digest":"62XV5uQbzZgGvxp9tD5TdVLSaMetnksTcuxnZzxqSxF1"},{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"Shared":{"initial_shared_version":66}},"objectType":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::state::State","objectId":"0xc57508ee0d4595e5a8728974a4a93a787d38f339757230d441e895422c07aba9","version":"557493695","previousVersion":"557486576","digest":"3khyLTP7S2Qp5pUnvuPPsWSjcRu2TAPWFycSAq47Jp9o"},{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"AddressOwner":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01"},"objectType":"0x2::coin::Coin<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","objectId":"0xef5b706f1fe9e2c6b42a43dc03daa741599a6d79f1e8ea030a8747ee3c6ba7e6","version":"557493695","previousVersion":"557350969","digest":"3ayiNB8sRCACWTVsnHp8efiPvZz22ZBhk1U7a1MbvvFt"}],"timestampMs":"1747278630259","checkpoint":"145311248"}}`),
			pastObjects:      []byte(`{"jsonrpc":"2.0","id":1,"result":[{"status":"VersionFound","details":{"objectId":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd","version":"557493695","digest":"62XV5uQbzZgGvxp9tD5TdVLSaMetnksTcuxnZzxqSxF1","content":{"dataType":"moveObject","type":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>>","hasPublicTransfer":false,"fields":{"id":{"id":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd"},"name":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"dummy_field":false}},"value":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"decimals":6,"info":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::ForeignInfo<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"native_decimals":6,"symbol":"USDT","token_address":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::external_address::ExternalAddress","fields":{"value":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::bytes32::Bytes32","fields":{"data":[206,1,14,96,175,237,178,39,23,189,99,25,47,84,20,90,63,150,90,51,187,130,210,199,2,158,178,206,30,32,130,100]}}}},"token_chain":1}},"treasury_cap":{"type":"0x2::coin::TreasuryCap<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"id":{"id":"0x220c42d8c6a2b1f9d2cd8a265607d07ecf1858f55d07cfca7ebeabe51fc7298a"},"total_supply":{"type":"0x2::balance::Supply<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"value":"5477949690"}}}},"upgrade_cap":{"type":"0x2::package::UpgradeCap","fields":{"id":{"id":"0x4231bc583a7768d1886f437b805da3b3178fd5ca8918c09eb36a46d4d2809c5d"},"package":"0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651","policy":0,"version":"1"}}}}}}}},{"status":"VersionFound","details":{"objectId":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd","version":"557350964","digest":"DLeLDr1cu6M1rxWuMbhiv2uGTGYDHm7JuPztbQyqQrsM","content":{"dataType":"moveObject","type":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>>","hasPublicTransfer":false,"fields":{"id":{"id":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd"},"name":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"dummy_field":false}},"value":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"decimals":6,"info":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::ForeignInfo<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"native_decimals":6,"symbol":"USDT","token_address":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::external_address::ExternalAddress","fields":{"value":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::bytes32::Bytes32","fields":{"data":[206,1,14,96,175,237,178,39,23,189,99,25,47,84,20,90,63,150,90,51,187,130,210,199,2,158,178,206,30,32,130,100]}}}},"token_chain":1}},"treasury_cap":{"type":"0x2::coin::TreasuryCap<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"id":{"id":"0x220c42d8c6a2b1f9d2cd8a265607d07ecf1858f55d07cfca7ebeabe51fc7298a"},"total_supply":{"type":"0x2::balance::Supply<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"value":"9617779333"}}}},"upgrade_cap":{"type":"0x2::package::UpgradeCap","fields":{"id":{"id":"0x4231bc583a7768d1886f437b805da3b3178fd5ca8918c09eb36a46d4d2809c5d"},"package":"0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651","policy":0,"version":"1"}}}}}}}}]}`),
			messagePublication: common.MessagePublication{
				TxID:             []byte("3YTfDnRtnLTx1wKR669jjFHznAxCXLHQZkshwk7K2oTw"),
				Timestamp:        time.UnixMilli(1747278630),
				Nonce:            0,
				Sequence:         211162,
				ConsistencyLevel: 0,
				EmitterChain:     21,
				EmitterAddress:   vaa.Address(decodeStringNoError("ccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5")),
				Payload:          decodeStringNoError("0100000000000000000000000000000000000000000000000000000000f6c0c98bce010e60afedb22717bd63192f54145a3f965a33bb82d2c7029eb2ce1e20826400012f1e9a1d5925ae0d328f84349bb5b3ea96e62011c6e0d1539337e3fc19719f8600010000000000000000000000000000000000000000000000000000000000000000"),
			},
		},
		{
			description:      "WrappedLowerDepositThanRequired",
			expectedState:    common.Anomalous,
			txDigest:         "3YTfDnRtnLTx1wKR669jjFHznAxCXLHQZkshwk7K2oTw",
			transactionBlock: []byte(`{"jsonrpc":"2.0","id":1,"result":{"digest":"3YTfDnRtnLTx1wKR669jjFHznAxCXLHQZkshwk7K2oTw","events":[{"id":{"txDigest":"3YTfDnRtnLTx1wKR669jjFHznAxCXLHQZkshwk7K2oTw","eventSeq":"0"},"packageId":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a","transactionModule":"publish_message","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::publish_message::WormholeMessage","parsedJson":{"consistency_level":0,"nonce":0,"payload":[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,246,192,201,139,206,1,14,96,175,237,178,39,23,189,99,25,47,84,20,90,63,150,90,51,187,130,210,199,2,158,178,206,30,32,130,100,0,1,47,30,154,29,89,37,174,13,50,143,132,52,155,181,179,234,150,230,32,17,198,224,209,83,147,55,227,252,25,113,159,134,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"sender":"0xccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5","sequence":"211162","timestamp":"1747278630"},"bcsEncoding":"base64","bcs":"zM7rKTSPcb3SL/70OioZwfW14XxcylQRUpEgGCZyreXaOAMAAAAAAAAAAACFAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9sDJi84BDmCv7bInF71jGS9UFFo/llozu4LSxwKess4eIIJkAAEvHpodWSWuDTKPhDSbtbPqluYgEcbg0VOTN+P8GXGfhgABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJlslaAAAAAA="}],"objectChanges":[{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"AddressOwner":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01"},"objectType":"0x2::coin::Coin<0x2::sui::SUI>","objectId":"0x58e20782ae501807df528e19d43b8c5a1838cfd1f48a33597be4619c18c24f80","version":"557493695","previousVersion":"557350969","digest":"2vNHn2448gNgHWWzsKz1bZ7K4SfgWd4s7zRfCCVSdMM1"},{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"Shared":{"initial_shared_version":64}},"objectType":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::state::State","objectId":"0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c","version":"557493695","previousVersion":"557493694","digest":"7JB9FuS1jJcP79PmwQhFu3s78JmJ1XPCj6CbXJhwziQk"},{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"ObjectOwner":"0x334881831bd89287554a6121087e498fa023ce52c037001b53a4563a00a281a5"},"objectType":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>>","objectId":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd","version":"557493695","previousVersion":"557350964","digest":"62XV5uQbzZgGvxp9tD5TdVLSaMetnksTcuxnZzxqSxF1"},{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"Shared":{"initial_shared_version":66}},"objectType":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::state::State","objectId":"0xc57508ee0d4595e5a8728974a4a93a787d38f339757230d441e895422c07aba9","version":"557493695","previousVersion":"557486576","digest":"3khyLTP7S2Qp5pUnvuPPsWSjcRu2TAPWFycSAq47Jp9o"},{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"AddressOwner":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01"},"objectType":"0x2::coin::Coin<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","objectId":"0xef5b706f1fe9e2c6b42a43dc03daa741599a6d79f1e8ea030a8747ee3c6ba7e6","version":"557493695","previousVersion":"557350969","digest":"3ayiNB8sRCACWTVsnHp8efiPvZz22ZBhk1U7a1MbvvFt"}],"timestampMs":"1747278630259","checkpoint":"145311248"}}`),
			pastObjects:      []byte(`{"jsonrpc":"2.0","id":1,"result":[{"status":"VersionFound","details":{"objectId":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd","version":"557493695","digest":"62XV5uQbzZgGvxp9tD5TdVLSaMetnksTcuxnZzxqSxF1","content":{"dataType":"moveObject","type":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>>","hasPublicTransfer":false,"fields":{"id":{"id":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd"},"name":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"dummy_field":false}},"value":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"decimals":6,"info":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::ForeignInfo<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"native_decimals":6,"symbol":"USDT","token_address":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::external_address::ExternalAddress","fields":{"value":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::bytes32::Bytes32","fields":{"data":[206,1,14,96,175,237,178,39,23,189,99,25,47,84,20,90,63,150,90,51,187,130,210,199,2,158,178,206,30,32,130,100]}}}},"token_chain":1}},"treasury_cap":{"type":"0x2::coin::TreasuryCap<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"id":{"id":"0x220c42d8c6a2b1f9d2cd8a265607d07ecf1858f55d07cfca7ebeabe51fc7298a"},"total_supply":{"type":"0x2::balance::Supply<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"value":"5477949690"}}}},"upgrade_cap":{"type":"0x2::package::UpgradeCap","fields":{"id":{"id":"0x4231bc583a7768d1886f437b805da3b3178fd5ca8918c09eb36a46d4d2809c5d"},"package":"0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651","policy":0,"version":"1"}}}}}}}},{"status":"VersionFound","details":{"objectId":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd","version":"557350964","digest":"DLeLDr1cu6M1rxWuMbhiv2uGTGYDHm7JuPztbQyqQrsM","content":{"dataType":"moveObject","type":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>>","hasPublicTransfer":false,"fields":{"id":{"id":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd"},"name":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"dummy_field":false}},"value":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"decimals":6,"info":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::ForeignInfo<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"native_decimals":6,"symbol":"USDT","token_address":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::external_address::ExternalAddress","fields":{"value":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::bytes32::Bytes32","fields":{"data":[206,1,14,96,175,237,178,39,23,189,99,25,47,84,20,90,63,150,90,51,187,130,210,199,2,158,178,206,30,32,130,100]}}}},"token_chain":1}},"treasury_cap":{"type":"0x2::coin::TreasuryCap<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"id":{"id":"0x220c42d8c6a2b1f9d2cd8a265607d07ecf1858f55d07cfca7ebeabe51fc7298a"},"total_supply":{"type":"0x2::balance::Supply<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"value":"9617779233"}}}},"upgrade_cap":{"type":"0x2::package::UpgradeCap","fields":{"id":{"id":"0x4231bc583a7768d1886f437b805da3b3178fd5ca8918c09eb36a46d4d2809c5d"},"package":"0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651","policy":0,"version":"1"}}}}}}}}]}`),
			messagePublication: common.MessagePublication{
				TxID:             []byte("3YTfDnRtnLTx1wKR669jjFHznAxCXLHQZkshwk7K2oTw"),
				Timestamp:        time.UnixMilli(1747278630),
				Nonce:            0,
				Sequence:         211162,
				ConsistencyLevel: 0,
				EmitterChain:     21,
				EmitterAddress:   vaa.Address(decodeStringNoError("ccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5")),
				Payload:          decodeStringNoError("0100000000000000000000000000000000000000000000000000000000f6c0c98bce010e60afedb22717bd63192f54145a3f965a33bb82d2c7029eb2ce1e20826400012f1e9a1d5925ae0d328f84349bb5b3ea96e62011c6e0d1539337e3fc19719f8600010000000000000000000000000000000000000000000000000000000000000000"),
			},
		},
		{
			description:      "WrappedHigherDepositThanRequired",
			expectedState:    common.Valid,
			txDigest:         "3YTfDnRtnLTx1wKR669jjFHznAxCXLHQZkshwk7K2oTw",
			transactionBlock: []byte(`{"jsonrpc":"2.0","id":1,"result":{"digest":"3YTfDnRtnLTx1wKR669jjFHznAxCXLHQZkshwk7K2oTw","events":[{"id":{"txDigest":"3YTfDnRtnLTx1wKR669jjFHznAxCXLHQZkshwk7K2oTw","eventSeq":"0"},"packageId":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a","transactionModule":"publish_message","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::publish_message::WormholeMessage","parsedJson":{"consistency_level":0,"nonce":0,"payload":[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,246,192,201,139,206,1,14,96,175,237,178,39,23,189,99,25,47,84,20,90,63,150,90,51,187,130,210,199,2,158,178,206,30,32,130,100,0,1,47,30,154,29,89,37,174,13,50,143,132,52,155,181,179,234,150,230,32,17,198,224,209,83,147,55,227,252,25,113,159,134,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"sender":"0xccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5","sequence":"211162","timestamp":"1747278630"},"bcsEncoding":"base64","bcs":"zM7rKTSPcb3SL/70OioZwfW14XxcylQRUpEgGCZyreXaOAMAAAAAAAAAAACFAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9sDJi84BDmCv7bInF71jGS9UFFo/llozu4LSxwKess4eIIJkAAEvHpodWSWuDTKPhDSbtbPqluYgEcbg0VOTN+P8GXGfhgABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJlslaAAAAAA="}],"objectChanges":[{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"AddressOwner":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01"},"objectType":"0x2::coin::Coin<0x2::sui::SUI>","objectId":"0x58e20782ae501807df528e19d43b8c5a1838cfd1f48a33597be4619c18c24f80","version":"557493695","previousVersion":"557350969","digest":"2vNHn2448gNgHWWzsKz1bZ7K4SfgWd4s7zRfCCVSdMM1"},{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"Shared":{"initial_shared_version":64}},"objectType":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::state::State","objectId":"0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c","version":"557493695","previousVersion":"557493694","digest":"7JB9FuS1jJcP79PmwQhFu3s78JmJ1XPCj6CbXJhwziQk"},{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"ObjectOwner":"0x334881831bd89287554a6121087e498fa023ce52c037001b53a4563a00a281a5"},"objectType":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>>","objectId":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd","version":"557493695","previousVersion":"557350964","digest":"62XV5uQbzZgGvxp9tD5TdVLSaMetnksTcuxnZzxqSxF1"},{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"Shared":{"initial_shared_version":66}},"objectType":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::state::State","objectId":"0xc57508ee0d4595e5a8728974a4a93a787d38f339757230d441e895422c07aba9","version":"557493695","previousVersion":"557486576","digest":"3khyLTP7S2Qp5pUnvuPPsWSjcRu2TAPWFycSAq47Jp9o"},{"type":"mutated","sender":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01","owner":{"AddressOwner":"0x6a0055cef8a44840cea847ca53bfa269194dc1ec6739383e431822617f95bc01"},"objectType":"0x2::coin::Coin<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","objectId":"0xef5b706f1fe9e2c6b42a43dc03daa741599a6d79f1e8ea030a8747ee3c6ba7e6","version":"557493695","previousVersion":"557350969","digest":"3ayiNB8sRCACWTVsnHp8efiPvZz22ZBhk1U7a1MbvvFt"}],"timestampMs":"1747278630259","checkpoint":"145311248"}}`),
			pastObjects:      []byte(`{"jsonrpc":"2.0","id":1,"result":[{"status":"VersionFound","details":{"objectId":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd","version":"557493695","digest":"62XV5uQbzZgGvxp9tD5TdVLSaMetnksTcuxnZzxqSxF1","content":{"dataType":"moveObject","type":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>>","hasPublicTransfer":false,"fields":{"id":{"id":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd"},"name":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"dummy_field":false}},"value":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"decimals":6,"info":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::ForeignInfo<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"native_decimals":6,"symbol":"USDT","token_address":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::external_address::ExternalAddress","fields":{"value":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::bytes32::Bytes32","fields":{"data":[206,1,14,96,175,237,178,39,23,189,99,25,47,84,20,90,63,150,90,51,187,130,210,199,2,158,178,206,30,32,130,100]}}}},"token_chain":1}},"treasury_cap":{"type":"0x2::coin::TreasuryCap<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"id":{"id":"0x220c42d8c6a2b1f9d2cd8a265607d07ecf1858f55d07cfca7ebeabe51fc7298a"},"total_supply":{"type":"0x2::balance::Supply<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"value":"5477949690"}}}},"upgrade_cap":{"type":"0x2::package::UpgradeCap","fields":{"id":{"id":"0x4231bc583a7768d1886f437b805da3b3178fd5ca8918c09eb36a46d4d2809c5d"},"package":"0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651","policy":0,"version":"1"}}}}}}}},{"status":"VersionFound","details":{"objectId":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd","version":"557350964","digest":"DLeLDr1cu6M1rxWuMbhiv2uGTGYDHm7JuPztbQyqQrsM","content":{"dataType":"moveObject","type":"0x2::dynamic_field::Field<0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>, 0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>>","hasPublicTransfer":false,"fields":{"id":{"id":"0xb4a85646ee0f7c22d54c57a06329c67f46e17420bf3654de7dec30ef9a7f18fd"},"name":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::token_registry::Key<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"dummy_field":false}},"value":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::WrappedAsset<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"decimals":6,"info":{"type":"0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d::wrapped_asset::ForeignInfo<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"native_decimals":6,"symbol":"USDT","token_address":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::external_address::ExternalAddress","fields":{"value":{"type":"0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a::bytes32::Bytes32","fields":{"data":[206,1,14,96,175,237,178,39,23,189,99,25,47,84,20,90,63,150,90,51,187,130,210,199,2,158,178,206,30,32,130,100]}}}},"token_chain":1}},"treasury_cap":{"type":"0x2::coin::TreasuryCap<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"id":{"id":"0x220c42d8c6a2b1f9d2cd8a265607d07ecf1858f55d07cfca7ebeabe51fc7298a"},"total_supply":{"type":"0x2::balance::Supply<0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651::coin::COIN>","fields":{"value":"9617779433"}}}},"upgrade_cap":{"type":"0x2::package::UpgradeCap","fields":{"id":{"id":"0x4231bc583a7768d1886f437b805da3b3178fd5ca8918c09eb36a46d4d2809c5d"},"package":"0xa69d563d6ff583e8171a7807b4c8c09434e0782aef8b849adb5c8609e9312651","policy":0,"version":"1"}}}}}}}}]}`),
			messagePublication: common.MessagePublication{
				TxID:             []byte("3YTfDnRtnLTx1wKR669jjFHznAxCXLHQZkshwk7K2oTw"),
				Timestamp:        time.UnixMilli(1747278630),
				Nonce:            0,
				Sequence:         211162,
				ConsistencyLevel: 0,
				EmitterChain:     21,
				EmitterAddress:   vaa.Address(decodeStringNoError("ccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5")),
				Payload:          decodeStringNoError("0100000000000000000000000000000000000000000000000000000000f6c0c98bce010e60afedb22717bd63192f54145a3f965a33bb82d2c7029eb2ce1e20826400012f1e9a1d5925ae0d328f84349bb5b3ea96e62011c6e0d1539337e3fc19719f8600010000000000000000000000000000000000000000000000000000000000000000"),
			},
		},
	}
)

func TestVerifyAndPublish_Samples(t *testing.T) {
	// This test runs verifyAndPublish against historical bridge transfers which should
	// be verified as valid.

	// This test uses mainnet values, since the samples come from mainnet transactions
	suiCoreContract := "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a"
	//nolint:gosec
	suiTokenBridgeEmitter := "0xccceeb29348f71bdd22ffef43a2a19c1f5b5e17c5cca5411529120182672ade5"
	//nolint:gosec
	suiTokenBridgeContract := "0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d"
	transactionModule := "publish_message"
	eventType := fmt.Sprintf("%s::%s::WormholeMessage", suiCoreContract, transactionModule)

	// Create mock API connection
	mockApiConnection := &MockSuiApiConnection{
		transactionBlockResponses:      make(map[string]txverifier.SuiGetTransactionBlockResponse),
		tryMultiGetPastObjectsResponse: make(map[string]txverifier.SuiTryMultiGetPastObjectsResponse),
	}

	suiTxVerifier := txverifier.NewSuiTransferVerifier(suiCoreContract, suiTokenBridgeEmitter, suiTokenBridgeContract, mockApiConnection)

	// Create message publication channel
	msgChan := make(chan *common.MessagePublication, 10)

	// Create watcher
	testWatcher := NewSuiWatcherForTest(msgChan, suiTxVerifier, eventType)

	// Create empty logger and context
	testCtx := context.TODO()
	testLogger := zap.NewNop()

	// Run verifyAndPublish on samples
	for _, sample := range Samples {

		t.Run(sample.description, func(t *testing.T) {
			// Set sample data in mock api
			var transactionBlockResponse txverifier.SuiGetTransactionBlockResponse
			_ = json.Unmarshal(sample.transactionBlock, &transactionBlockResponse)

			mockApiConnection.SetTransactionBlock(sample.txDigest, transactionBlockResponse)

			var pastObjects txverifier.SuiTryMultiGetPastObjectsResponse
			_ = json.Unmarshal(sample.pastObjects, &pastObjects)

			objectId, _ := pastObjects.GetObjectId()
			version, _ := pastObjects.Result[0].GetVersion()
			previousVersion, _ := pastObjects.Result[1].GetVersion()

			mockApiConnection.SetPastObjects(objectId, version, previousVersion, pastObjects)

			// call verify and publish
			_ = testWatcher.verifyAndPublish(testCtx, &sample.messagePublication, sample.txDigest, testLogger)

			newMessagePublication := <-msgChan
			require.Equal(t, sample.expectedState, newMessagePublication.VerificationState())
		})

	}
}
